package com.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.ssm.domain.SysFile;
import com.ssm.service.IFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @description:
 * @author: Mr.xx
 * @date: 2021/3/28 12:56
 */
@Controller
//@RequestMapping("file")
public class TestController {

    @Autowired
    private IFileService fileService;

//    @RequestMapping("/select.do")
    public ModelAndView selectFile(@RequestParam(name="page",required = true, defaultValue = "1") Integer page,
                                   @RequestParam(name="size",required = true, defaultValue = "5") Integer size,
                                   @RequestParam(name="keyWord",defaultValue = "") String keyWord)
            throws Exception {
        ModelAndView mv = new ModelAndView();
        mv.addObject("keyWord", keyWord);
        List<SysFile> fileList = fileService.selectFile(page,size,keyWord);
        PageInfo pageInfo = new PageInfo(fileList);
        mv.addObject("pageInfo", pageInfo);
        mv.setViewName("file-list-select");
        return mv;
    }
}
